{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib widget\n",
    "from IPython.display import display\n",
    "from ipywidgets import widgets\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "\n",
    "button = widgets.Button(description=\"Click Me!\")\n",
    "\n",
    "def on_button_clicked(b):\n",
    "\tX = np.linspace(0, 2*np.pi)\n",
    "\tY = np.sin(X)\n",
    "\n",
    "\t_, ax = plt.subplots()\n",
    "\tax.plot(X, Y)\n",
    "\n",
    "display(button)\n",
    "button.on_click(on_button_clicked)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "display(button)"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
